'''
封装 logging类

'''

import logging
class LoggerHanndler():

    def initlog(self,
                name,
                levelname='DEBUG',
                file=None,
                format='%(filename)s-%(lineno)s-%(name)s-%(levelname)s-%(message)s'
                ):
        # 1.初始化，
        loger = logging.getLogger(name)
        #收集器 等级
        loger.setLevel(levelname)

        # 处理器
        # 格式
        fmt = logging.Formatter(format)
        if file:
            file_handler = logging.FileHandler(file)

            file_handler.setLevel(levelname)

            file_handler.setFormatter(fmt)

        loger.addHandler(file_handler)
        # 在控制台输出的报错
        strem_handler = logging.StreamHandler()

        strem_handler.setLevel(levelname)

        loger.addHandler(strem_handler)
        strem_handler.setFormatter(fmt)

        self.loger = loger
    def debug(self,msg):
        return self.loger.debug(msg)
    def info(self,msg):
        return self.loger.info(msg)
    def warning(self,msg):
        return self.loger.warning(msg)
    def crital(self,msg):
        return self.loger.critical(msg)

    # 一直有调用另一个logger对象，要想到是 继承